package com.xoms.admin.persist.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.xoms.admin.model.ProStoreBean;
import com.xoms.admin.persist.dao.ProStoreDao;
import com.xoms.util.StringUtil;

@Repository
public class ProStoreImpl extends BaseImpl implements ProStoreDao {
	
	final String NAME_SPACE = NAME_SPACE_HEADER + ".ProStoreMapper";

	@Override
	public int selectStoreCount(String key, int type) {
		Map<String, Object> params = new HashMap<String, Object>();
		if (!StringUtil.isEmpty(key)) {
			params.put("key", key);
		}
		params.put("type", type);
		return sqlSessionTemplate.selectOne(NAME_SPACE + ".selectCount", params);
	}

	@Override
	public List<ProStoreBean> selectStoreList(String key, int page, int pagesize, int type) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("start", page * pagesize);
		params.put("length", pagesize);
		if (!StringUtil.isEmpty(key)) {
			params.put("key", key);
		}
		params.put("type", type);
		return sqlSessionTemplate.selectList(NAME_SPACE + ".selectList", params);
	
	}

	@Override
	public int del(String sid) {
		return sqlSessionTemplate.delete(NAME_SPACE + ".del", sid);
	}

	@Override
	public int update(ProStoreBean data) {
		return sqlSessionTemplate.update(NAME_SPACE + ".update", data);
		
	}

	@Override
	public int insert(ProStoreBean data) {
		return sqlSessionTemplate.insert(NAME_SPACE + ".insert", data);
	}

	@Override
	public ProStoreBean selectOneById(String sid) {
		return sqlSessionTemplate.selectOne(NAME_SPACE + ".selectOneById", sid);
	}

}
